import java.util.ArrayList;
import java.util.List;

class ProductCategory {
    private String categoryName;
    private List<Product> products;

    public ProductCategory(String categoryName) {
        this.categoryName = categoryName;
        this.products = new ArrayList<>();
    }

    public String getCategoryName() {
        return categoryName;
    }

    public List<Product> getProducts() {
        return products;
    }

    public void addProduct(Product product) {
        products.add(product);
    }
}
package com.shop.controller.admin;

        import java.util.ArrayList;
        import java.util.List;

public class ProductCategory {
    private String categoryName;
    private List<Product> products;

    public ProductCategory(String categoryName) {
        this.categoryName = categoryName;
        this.products = new ArrayList<>();
    }

    public String getCategoryName() {
        return categoryName;
    }

    public void addProduct(Product product) {
        products.add(product);
    }

    public boolean removeProduct(Product product) {
        return products.remove(product);
    }

    public List<Product> getProducts() {
        return products;
    }

    @Override
    public String toString() {
        return "ProductCategory{categoryName='" + categoryName + "', products=" + products + "}";
    }
}
package com.shop.controller.admin;

        import java.util.ArrayList;
        import java.util.List;

public class ProductCategory {
    private String categoryName;
    private List<Product> products;
    private boolean isEnabled;

    public ProductCategory(String categoryName) {
        this.categoryName = categoryName;
        this.products = new ArrayList<>();
        this.isEnabled = true;
    }

    public String getCategoryName() {
        return categoryName;
    }

    public void addProduct(Product product) {
        if (isEnabled) {
            products.add(product);
        } else {
            System.out.println("分类 " + categoryName + " 已禁用，无法添加商品。");
        }
    }

    public boolean removeProduct(Product product) {
        if (isEnabled) {
            return products.remove(product);
        } else {
            System.out.println("分类 " + categoryName + " 已禁用，无法删除商品。");
            return false;
        }
    }

    public List<Product> getProducts() {
        return products;
    }

    public boolean isEnabled() {
        return isEnabled;
    }

    public void enable() {
        this.isEnabled = true;
    }

    public void disable() {
        this.isEnabled = false;
    }

    @Override
    public String toString() {
        return "ProductCategory{categoryName='" + categoryName + "', products=" + products + ", isEnabled=" + isEnabled + "}";
    }
}